package com.alone.openai.api.core.param;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Alone
 * @date 2023/3/23 2:11 下午
 */
@Data
public class ImageGenerationResponse {

    private int created;
    private List<ImageData> data;

    public String getContent() {
        if (CollUtil.isNotEmpty(data)) {
            return data.stream().map(ImageData::getUrl).collect(Collectors.joining(","));
        }
        return "";
    }

    public String getHtmlContent() {
        String content = getContent();
        if (StrUtil.isNotBlank(content)) {
            content = content.replace(",", "<br/>");
        }
        return content;
    }
}
